package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.system.bo.ZsyyCommunityUserEditBo;
import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.vo.ZsyyCommunityMonthFeeVo;
import com.ruoyi.system.bo.ZsyyCommunityMonthFeeQueryBo;
import com.ruoyi.system.bo.ZsyyCommunityMonthFeeAddBo;
import com.ruoyi.system.bo.ZsyyCommunityMonthFeeEditBo;
import com.ruoyi.system.service.IZsyyCommunityMonthFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 物业缴费记录 Controller
 *
 * @author wangghua
 * @date 2021-07-14
 */
@ApiIgnore
@Api(value = "物业缴费记录 控制器", tags = {"物业缴费记录 管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/communityMonthFee")
public class ZsyyCommunityMonthFeeController extends BaseController {

    private final IZsyyCommunityMonthFeeService iZsyyCommunityMonthFeeService;

    /**
     * 查询物业缴费记录 列表
     */
    @ApiOperation("查询物业缴费记录 列表")
    @PreAuthorize("@ss.hasPermi('system:communityMonthFee:list')")
    @GetMapping("/list")
    public TableDataInfo<ZsyyCommunityMonthFeeVo> list(@Validated ZsyyCommunityMonthFeeQueryBo bo) {
        return iZsyyCommunityMonthFeeService.queryPageList(bo);
    }

    /**
     * 导出物业缴费记录 列表
     */
    @ApiOperation("导出物业缴费记录 列表")
    @PreAuthorize("@ss.hasPermi('system:communityMonthFee:export')")
    @Log(title = "物业缴费记录 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ZsyyCommunityMonthFeeVo> export(@Validated ZsyyCommunityMonthFeeQueryBo bo) {
        List<ZsyyCommunityMonthFeeVo> list = iZsyyCommunityMonthFeeService.queryList(bo);
        ExcelUtil<ZsyyCommunityMonthFeeVo> util = new ExcelUtil<ZsyyCommunityMonthFeeVo>(ZsyyCommunityMonthFeeVo.class);
        return util.exportExcel(list, "物业缴费记录 ");
    }

    /**
     * 获取物业缴费记录 详细信息
     */
    @ApiOperation("获取物业缴费记录 详细信息")
    @PreAuthorize("@ss.hasPermi('system:communityMonthFee:query')")
    @GetMapping("/{id}")
    public AjaxResult<ZsyyCommunityMonthFeeVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iZsyyCommunityMonthFeeService.queryById(id));
    }

    /**
     * 新增物业缴费记录
     */
    @ApiOperation("新增物业缴费记录 ")
    @PreAuthorize("@ss.hasPermi('system:communityMonthFee:add')")
    @Log(title = "物业缴费记录 ", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody ZsyyCommunityUserEditBo bo) {
        return toAjax(iZsyyCommunityMonthFeeService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改物业缴费记录
     */
    @ApiOperation("修改物业缴费记录 ")
    @PreAuthorize("@ss.hasPermi('system:communityMonthFee:edit')")
    @Log(title = "物业缴费记录 ", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody ZsyyCommunityMonthFeeEditBo bo) {
        return toAjax(iZsyyCommunityMonthFeeService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除物业缴费记录
     */
    @ApiOperation("删除物业缴费记录 ")
    @PreAuthorize("@ss.hasPermi('system:communityMonthFee:remove')")
    @Log(title = "物业缴费记录 " , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iZsyyCommunityMonthFeeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
